<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>模拟销售</title>
    <!-- 新 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="http://localhost:8080/supermarket/css/bootstrap.min.css">
    <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
    <script src="http://localhost:8080/supermarket/js/jquery.min.js"></script>
    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script src="http://localhost:8080/supermarket/js/bootstrap.min.js"></script>
</head>

<body>
<div style="padding:0px; margin:0px;">
    <ul class="breadcrumb" style="  margin:0px; " >>
        <li>销售管理</li>
        <li>模拟销售</li>
    </ul>
</div>
<form  class="form-horizontal">
    <h5 class="page-header alert-info" style="padding:10px; margin:0px; margin-bottom:5px;">基本信息</h5>
    <!--开始 -->
    <div class="row">
        <div class="col-sm-5">
            <div class="form-group">
                <label class="col-sm-3 control-label">商品条码</label>
                <div class="col-sm-9">
                    <input type="text" name="product_bar_code" id="bar" class="form-control input-sm" />
                </div>
            </div>
        </div>
        <div class="col-sm-5">
            <div class="form-group">
                <label class="col-sm-3 control-label">销售价格</label>
                <div class="col-sm-9">
                    <input type="text" id="price" name="sale_price" readonly="readonly" class="form-control input-sm" />
                </div>
            </div>
        </div>
    </div>
    <!--结束 -->
    <!--开始 -->
    <div class="row">
        <div class="col-sm-5">
            <div class="form-group">
                <label class="col-sm-3 control-label">销售日期</label>
                <div class="col-sm-9">
                    <input type="date" id="date" name="sale_date" class="form-control input-sm" />
                </div>
            </div>
        </div>
        <div class="col-sm-5">
            <div class="form-group">
                <label class="col-sm-3 control-label">销售数量</label>
                <div class="col-sm-9">
                    <input type="text" id="count" name="sale_count" class="form-control input-sm" />
                </div>
            </div>
        </div>
    </div>
    <!--结束 -->
    <div class="row">
        <div class="col-sm-3 col-sm-offset-4">
            <input  type="button" id="button" class="btn btn-success" value="提交"/>
        </div>
    </div>
</form>
<script>

//用于回显价格
    $("#bar").blur(function () {
        $.post("http://localhost:8080/supermarket/saleServlet?method=selectPaice",{
            bar:$("#bar").val()
        },function (data) {
            $("#price").val(data);
        });
    });
        $("#button").click(function () {
        $.post("http://localhost:8080/supermarket/saleServlet?method=Add",
            {
                product_bar_code:$("#bar").val(),
                sale_price:$("#price").val(),
                sale_date:$("#date").val(),
                sale_count:$("#count").val()
            },function (data) {
                alert(data);
        });
        });

</script>
</body>
</html>
